#include "page.h"

/**
 * Initializes a new page table
 * @param pageTable to be initialized
 * @param size of the process page table
 */
void pagTabCreate(PAGE pageTable[], int processSize) {
    int i;
    for (i = 0; i < processSize; i++) {
        pageTable[i].number = i + 1;
        pageTable[i].reference = false;
        pageTable[i].dirt = false;
        pageTable[i].accesses = 0;
        pageTable[i].faults = 0;
        pageTable[i].replaces = 0;
        pageTable[i].address = NULL;
    }
}

/**
 * Print pages status of a page table
 * @param pageTable to be printed
 * @param size of the process page table
 */
void pagTabPrint(PAGE pageTable[], int size) {
    int i;
    printf("PAGE\tACCESS\tFAULT\tREPLACE\n");
    for (i = 0; i < size; i++) {
        if (pageTable[i].accesses != 0) {
            printf("%d\t", pageTable[i].number);
            printf("%d\t", pageTable[i].accesses);
            printf("%d\t", pageTable[i].faults);
            printf("%d\t\n", pageTable[i].replaces);
        }
    }
}
